<template>
  <div class="app-container">
    <el-form :model="queryParams" inline ref="queryForm" size="small" label-width="68px">
      <el-form-item label="客户名称" prop="customerName">
        <el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">
          搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" style="width: 100%">
      <el-table-column type="index" label="序号" width="120" align="center" />
      <el-table-column prop="customerName" label="客户名称" align="center" />
      <el-table-column prop="projectCount" label="项目数量" align="center" />
      <el-table-column prop="buildingCount" label="建筑构造物数量" align="center" />
      <el-table-column prop="address" label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleDetail(scope.row.customerId)">
            详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { getProjectCountAndBuildingCountList } from "@/api/plan-produce/task";

export default {
  name: "Task-index",
  data() {
    return {
      loading: false, // 遮罩层
      total: 0, // 总条数
      dataList: [], // 数据列表
      detailShow: false, // 详情页面
      // 查询参数
      queryParams: {
        customerName: null,
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },

  methods: {
    getList() {
      this.loading = true;
      getProjectCountAndBuildingCountList(this.queryParams)
        .then((res) => {
          this.dataList = res.rows;
          this.total = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 跳转详情
    handleDetail(id) {
      this.$router.push({
        path: "/contract/maintenanceList",
        query: {
          customerId: id,
        },
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.mapSty {
  width: 100%;
  height: 450px;
  position: relative;
}

#allMap {
  width: 100%;
  height: 450px;
}

.textSty {
  font-size: 14px;
  color: rgb(102, 102, 102);
}

.textIconSty {
  margin-left: 10px;
  font-size: 12px;
  color: rgb(102, 102, 102);
  margin-right: 0.3rem;

  .listIcon {
    padding: 0 5px;
  }
}

.text-with-line {
  text-decoration: line-through;
}

::v-deep .el-card__body {
  padding: 0;
}
</style>
